import * as THREE from 'three';

function addSomeGeometry( scene ) {
    // ----------------------- 创建多个几何体 ----------------------- 

    // 添加一个球体
    const sphereGeometry = new THREE.SphereGeometry(1, 32, 32); // 半径, 水平分段, 垂直分段
    const sphereMaterial = new THREE.MeshStandardMaterial({ 
        color: 0xff0000, 
        roughness: 0.3,
        metalness: 0.7
    });
    const sphere = new THREE.Mesh(sphereGeometry, sphereMaterial);
    sphere.position.set(3, 0, 0); // 放在立方体右侧
    scene.add(sphere);

    // 添加一个圆柱体
    const cylinderGeometry = new THREE.CylinderGeometry(0.5, 1, 2, 32); // 顶部半径, 底部半径, 高度, 分段
    const cylinderMaterial = new THREE.MeshStandardMaterial({ 
        color: 0x00ff00,
        roughness: 0.5,
        metalness: 0.5
    });
    const cylinder = new THREE.Mesh(cylinderGeometry, cylinderMaterial);
    cylinder.position.set(0, 0, 3); // 放在立方体前面
    scene.add(cylinder);

    // 添加一个环面几何体（甜甜圈形状）
    const torusGeometry = new THREE.TorusGeometry(1, 0.3, 16, 100); // 环半径, 管道半径, 径向段, 管道段
    const torusMaterial = new THREE.MeshStandardMaterial({ 
        color: 0x0000ff,
        roughness: 0.2,
        metalness: 0.8
    });
    const torus = new THREE.Mesh(torusGeometry, torusMaterial);
    torus.position.set(-3, 0, 0); // 放在立方体左侧
    torus.rotation.x = Math.PI / 3; // 旋转90度
    scene.add(torus);

    // 添加一个平面
    const planeGeometry = new THREE.PlaneGeometry(10, 10); // 宽度, 高度
    const planeMaterial = new THREE.MeshStandardMaterial({ 
        color: 0xcccccc,
        roughness: 0.9,
        metalness: 0.1,
        side: THREE.DoubleSide // 双面可见
    });
    const plane = new THREE.Mesh(planeGeometry, planeMaterial);
    plane.position.set(0, -2, 0); // 放在所有物体下方作为地面
    plane.rotation.x = Math.PI / 2; // 水平放置
    scene.add(plane);
}

const Geom = {
    addSomeGeometry
};

export default Geom;
